//
//  SearchStoreTableViewCell.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/8.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "SearchStoreTableViewCell.h"

@implementation SearchStoreTableViewCell{
    GLGWLabel * storeNamelabel;
    GLGWLabel * saleLabel;
    GLGWLabel * dealLabel;
    GLGWLabel * mainLabel;
    GLGWButton * p_but;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        GLGWView * storeBankgroundView = [[GLGWView alloc] initWithFrame:CGRectMake(kWidthProportion_In_iPhoneTriploid(15), kHeightProportion_In_iPhoneTriploid(10), KScreenWidth-kWidthProportion_In_iPhoneTriploid(30), kHeightProportion_In_iPhoneTriploid(106)) inSuperView:self];
        storeBankgroundView.backgroundColor = [UIColor whiteColor];
        [storeBankgroundView setViewShadowWidth:3.0 theCornerRadius:3.0];
        //
        GLGWView * leftYeView = [[GLGWView alloc] initWithFrame:CGRectMake(0, 0, kWidthProportion_In_iPhoneTriploid(6), storeBankgroundView.height) inSuperView:storeBankgroundView];
        UIRectCorner type = UIRectCornerTopLeft | UIRectCornerBottomLeft;
        [leftYeView setBorderWithCornerRadius:3.0 borderWidth:0 borderColor:[UIColor whiteColor] type:type];
        leftYeView.backgroundColor = [UIColor colorWithHexString:@"#A89A60"];
        //
        storeNamelabel = [[GLGWLabel alloc] initWithFrame:CGRectMake(kX_With_View(leftYeView, 15), kHeightProportion_In_iPhoneTriploid(15), storeBankgroundView.width - kX_With_View(leftYeView, 15)-kWidthProportion_In_iPhoneTriploid(80), kHeightProportion_In_iPhoneTriploid(22)) theFont:SYSTEMFONT(16) theColor:kColor_Rule_Black inSuperView:storeBankgroundView];
//        storeNamelabel.backgroundColor = kRandomColor;
        //
        if (self.accountType == AccountType_Ordinary) {
            p_but = [[GLGWButton alloc] initWithFrame:CGRectMake(kX_With_View(storeNamelabel, 15), kHeightProportion_In_iPhoneTriploid(17), kWidthProportion_In_iPhoneTriploid(50), kHeightProportion_In_iPhoneTriploid(18)) hTitle:@"进店" titleLableFont:SYSTEMFONT(12) titleLableColor:kColor_Rule_Yellow theCornerRadius:kHeightProportion_In_iPhoneTriploid(9) theBorderWidth:1 theBorderColor:kColor_Rule_Yellow backgroundColr:[UIColor whiteColor] inSuperView:storeBankgroundView];
        }else{
            p_but = [[GLGWButton alloc] initWithFrame:CGRectMake(kX_With_View(storeNamelabel, 10), kHeightProportion_In_iPhoneTriploid(10), kWidthProportion_In_iPhoneTriploid(60), kHeightProportion_In_iPhoneTriploid(25)) hTitle:@"进入店铺" titleLableFont:SYSTEMFONT(12) titleLableColor:[UIColor whiteColor] theCornerRadius:3.0 backgroundColr:kColor_Rule_Yellow inSuperView:storeBankgroundView];
        }
        
        [p_but addTarget:self action:@selector(pushStoreAction) forControlEvents:UIControlEventTouchUpInside];
        //
        saleLabel = [[GLGWLabel alloc] initWithFrame:CGRectMake(storeNamelabel.x, kY_With_View(storeNamelabel, 10), kWidthProportion_In_iPhoneTriploid(90), kHeightProportion_In_iPhoneTriploid(17)) theFont:SYSTEMFONT(12) theColor:[UIColor colorWithHexString:@"#666666"] inSuperView:storeBankgroundView];
        //
        dealLabel = [[GLGWLabel alloc] initWithFrame:CGRectMake(kX_With_View(saleLabel, 20), saleLabel.y, saleLabel.width, saleLabel.height) theFont:SYSTEMFONT(12) theColor:[UIColor colorWithHexString:@"#666666"] inSuperView:storeBankgroundView];
        //
        mainLabel = [[GLGWLabel alloc] initWithFrame:CGRectMake(storeNamelabel.x, kY_With_View(saleLabel, 10), storeBankgroundView.width - storeNamelabel.x - kWidthProportion_In_iPhoneTriploid(15), kHeightProportion_In_iPhoneTriploid(17)) theFont:SYSTEMFONT(12) theColor:[UIColor colorWithHexString:@"#999999"] inSuperView:storeBankgroundView];
    }
    return self;
}

-(void)pushStoreAction{
    if (self.Block_PushStore) {
        self.Block_PushStore();
    }
}

-(void)setHightStoreModel:(HightQualityStoreModel_Infos *)hightStoreModel{
    _hightStoreModel = hightStoreModel;
    storeNamelabel.text = _hightStoreModel.shopName;
    saleLabel.attributedText = [GLGWLabel addImageName:@"icon_zaishoushangpin" theImageFram:CGRectMake(0, -kHeightProportion_In_iPhoneTriploid(2.5), kHeightProportion_In_iPhoneTriploid(14), kHeightProportion_In_iPhoneTriploid(14)) theTextString:[NSString stringWithFormat:@" 在售商品%ld件",(long)_hightStoreModel.productNum] atImageIndex:0];
    //
    dealLabel.attributedText = [GLGWLabel addImageName:@"icon_chengjiao" theImageFram:CGRectMake(0, -kHeightProportion_In_iPhoneTriploid(3), kHeightProportion_In_iPhoneTriploid(14), kHeightProportion_In_iPhoneTriploid(14)) theTextString:[NSString stringWithFormat:@" 成交%ld笔",(long)_hightStoreModel.volume] atImageIndex:0];
    //
    mainLabel.text = _hightStoreModel.mainProduct;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
